﻿using UnityEngine;
using System.Collections;
using System;

public class finishLevelCommand : ICommand {

	private bool needResponse;

	public finishLevelCommand() {
		needResponse = true;
	}

	public string getCommand() {
		int finished = GameManager.getInstance ().GetFinished ();
		Application.LoadLevel (3);
		return "finishlevel:" + finished;
	}

	public void respond(string command, string content) {
		if (command.Equals ("launchlevel")) {
			int status = Int32.Parse(content);
			GameManager.getInstance().SetStatus(status);
			Application.LoadLevel(2);
			GameManager.getInstance().Reset();
			needResponse = true;
		}
	}

	public bool needsToRespond() {
		if (needResponse) {
			if(GameManager.getInstance().GetFinished() != 0) {
				needResponse = false;
				return true;
			}
			return false;
		}
		return false;
	}
}
